package com.sunhy.redisbloom1.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;

@Configuration
public class RedissonConfig {

    @Bean
    public RedissonClient redissonInstance() {
        Config config = null;
        try {
            config = Config.fromYAML( new ClassPathResource("redisson.yaml").getInputStream() );
        } catch (IOException e) {
            e.printStackTrace();
        }
        // 构造Redisson
        RedissonClient redissonClient = Redisson.create(config);

        return redissonClient;
    }

}
